const userService=require('../service/user')

const userController=async(ctx,next)=>{
    // const result=await userService.
    ctx.body={
        code:200,
        message:'2007B'
    }
}
//查询
const queryController=async(ctx,next)=>{
    let results=await userService.queryService();
    if(results){
        ctx.body={
            code:200,
            message:'2007B'
        }
    }
    else
    {
        ctx.body={
            code:403,
            message:'2008B'
        }
    }
}
// 添加
const addToController=async(ctx,next)=>{
    const {username,password,nickname,age,phone}=ctx.request.body;
    let results = await userService.addToService(ctx);
    if(results){
        ctx.body={
            code:200,
            message:'2007B'
        }
    }
    else
    {
        ctx.body={
            code:403,
            message:'2008B'
        }
    }
}
// 删除
const deldeteController=async(ctx,next)=>{
    let results=await userService.deldeteService(ctx)
    if(results){
        ctx.body={
            code:200,
            message:'2007B'
        }
    }
    else
    {
        ctx.body={
            code:403,
            message:'2008B'
        }
    }

}
// 改
const updateController=async(ctx,next)=>
{
    let results=await userService.updateService(ctx)
    if(results){
        ctx.body={
            code:200,
            message:'2007B'
        }
    }
    else
    {
        ctx.body={
            code:403,
            message:'2008B'
        }
    }
}
module.exports={
    userController,
    queryController,
    addToController,
    deldeteController,
    updateController
}